package com.gxar.navigation.server.base.model.node.mapper;

import com.gxar.navigation.server.base.model.node.vo.request.NodeCreateRequest;
import com.gxar.navigation.server.base.model.node.vo.request.NodeUpdateRequest;
import com.gxar.navigation.server.base.model.node.vo.response.NodeCreateResponse;
import com.gxar.navigation.server.base.model.node.vo.response.NodeInfoResponse;
import com.gxar.navigation.server.base.model.node.vo.response.NodePageResponse;
import com.gxar.navigation.server.base.model.node.vo.response.NodeUpdateResponse;
import com.gxar.navigation.server.db.model.NodeEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @author Linsy
 * @version 1.0
 * @created 2023/7/8 10:45 AM
 */
@Mapper
public interface NodeMapStruct {
    NodeMapStruct INSTANCE = Mappers.getMapper(NodeMapStruct.class);

    /**
     * 实体转换成视图对象
     *
     * @param node 实体
     * @return 视图对象
     */
    @Mapping(target = "id", expression = "java(java.lang.String.valueOf(node.getId()))")
    NodePageResponse entityToPageResponse(NodeEntity node);

    /**
     * 实体集合转视图对象集合
     *
     * @param nodes 实体集合
     * @return 响应
     */
    List<NodePageResponse> entitiesToPageResponse(List<NodeEntity> nodes);

    /**
     * 实体转详细信息
     *
     * @param node 素材实体
     * @return 素材详细视图模型
     */
    @Mapping(target = "id", expression = "java(java.lang.String.valueOf(node.getId()))")
    NodeInfoResponse entityToInfoResponse(NodeEntity node);

    /**
     * 实体转创建响应
     *
     * @param node 实体
     * @return 响应
     */
    @Mapping(target = "id", expression = "java(java.lang.String.valueOf(node.getId()))")
    NodeCreateResponse entityToCreateResponse(NodeEntity node);

    /**
     * 实体转更新响应
     *
     * @param node 实体
     * @return 响应
     */
    @Mapping(target = "id", expression = "java(java.lang.String.valueOf(node.getId()))")
    NodeUpdateResponse entityToUpdateResponse(NodeEntity node);

    /**
     * 创建请求转实体
     *
     * @param createRequest 创建请求
     * @return 实体
     */
    NodeEntity createRequestToEntity(NodeCreateRequest createRequest);

    /**
     * 更新请求转实体
     *
     * @param updateRequest 更新请求
     * @return 实体
     */
    NodeEntity updateRequestToEntity(NodeUpdateRequest updateRequest);

}
